using Microsoft.AspNetCore.DataProtection.KeyManagement;
using System;
using System.IO;
using System.Text.Json;

namespace Util
{
    internal class GetConfigs
    {
        static GetConfigs()
        {
            try
            {
                using var stream = File.OpenRead("appsettings.json");
                using var json = JsonDocument.Parse(stream);
                var config = json.RootElement.GetProperty("AliPay");
                AppID = config.GetProperty("AppID").GetString()!;
                AppSecret = config.GetProperty("AppSecret").GetString()!;
                PrivateKey  = config.GetProperty("Public_key").GetString()!;
                NotifyUrl = config.GetProperty("NotifyUrl").GetString()!;
                Public_key = config.GetProperty("Public_key").GetString()!;

            }
            catch (Exception ex)
            {
                throw new Exception("加载配置文件 appsettings.json 失败，请查看 `InnerException` 了解具体失败原因", ex);
            }
        }

        public static string AppID;
        public static string AppSecret;

        /// <summary>
        /// 商户密钥
        /// </summary>
        public static string PrivateKey;

        public static string Public_key;

        public static string NotifyUrl;

    }
}
